package org.example;

import org.example.bean.ComsumerComponet;
import org.example.config.ConsumerConfiguration;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/**
 * Description: 消费端
 * Author: e
 * CreateDate: 2021-05-19
 */
public class ConsumerMain {


    public static void main(String[] args) throws Exception {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
        // 获取消费者组件
        ComsumerComponet helloService = context.getBean(ComsumerComponet.class);

        ScheduledExecutorService executor = Executors.newScheduledThreadPool(6);


        //使用线程池 不断调用Dubbo服务的3个方法
        for (int i = 0; i < 50000; i++) {
            executor.execute(() -> {
                helloService.sayHello1("zhangsan");
                helloService.sayHello2("lisi");
                helloService.sayHello3("wangwu");
            });
        }
        System.in.read();
    }


}
